USE [Journey]
GO

ALTER TABLE [dbo].[journey_rolePermissions] DROP CONSTRAINT [FK_dbo.journey_rolePermissions_dbo.journey_roles_roleId]
GO

ALTER TABLE [dbo].[journey_rolePermissions] DROP CONSTRAINT [FK_dbo.journey_rolePermissions_dbo.journey_permissions_permissionId]
GO

/****** Object:  Table [dbo].[journey_rolePermissions]    Script Date: 2014/7/12 14:52:22 ******/
DROP TABLE [dbo].[journey_rolePermissions]
GO

/****** Object:  Table [dbo].[journey_rolePermissions]    Script Date: 2014/7/12 14:52:22 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[journey_rolePermissions](
	[roleId] [int] NOT NULL,
	[permissionId] [int] NOT NULL,
 CONSTRAINT [PK_dbo.journey_rolePermissions] PRIMARY KEY CLUSTERED 
(
	[roleId] ASC,
	[permissionId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[journey_rolePermissions]  WITH CHECK ADD  CONSTRAINT [FK_dbo.journey_rolePermissions_dbo.journey_permissions_permissionId] FOREIGN KEY([permissionId])
REFERENCES [dbo].[journey_permissions] ([Id])
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[journey_rolePermissions] CHECK CONSTRAINT [FK_dbo.journey_rolePermissions_dbo.journey_permissions_permissionId]
GO

ALTER TABLE [dbo].[journey_rolePermissions]  WITH CHECK ADD  CONSTRAINT [FK_dbo.journey_rolePermissions_dbo.journey_roles_roleId] FOREIGN KEY([roleId])
REFERENCES [dbo].[journey_roles] ([Id])
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[journey_rolePermissions] CHECK CONSTRAINT [FK_dbo.journey_rolePermissions_dbo.journey_roles_roleId]
GO


